package com.water.util;

public class PathUtil {
	public static String addPathStyle(String str) {
		if (str == null) {
			return "";
		}
		while (str.endsWith("/")) {
			str = str.substring(0, str.length() - 1);
		}
		if (!str.startsWith("/")) {
			return "/" + str;
		} else {
			return str;
		}
	}

	public static String removePathStyle(String str) {
		if (str == null) {
			return "";
		}
		while (str.endsWith("/")) {
			str = str.substring(0, str.length() - 1);
		}
		if (str.startsWith("/")) {
			return str.substring(1);
		} else {
			return str;
		}
	}

	public static String transcate(String a, String b) {
		if (a.endsWith("/") && b.endsWith("/")) {
			return a + b.substring(1);
		}
		if (!a.endsWith("/") && !b.endsWith("/")) {
			return a + "/" + b;
		}
		return a + b;
	}
}
